<template>
  <div>
    <footer class="footer" v-if="this.list.length">
      <span class="todo-count" v-if="last"><strong>{{last}}</strong>剩余</span>
      <ul class="filters">
        <li>
          <a :class="{selected:type ==='selected'}"  @click.prevent="changeType('selected')" href="#/" >全部</a>
        </li>
        <li>
          <a :class="{selected:type ==='active'}"  @click.prevent="changeType('active')" href="#/active">进行中</a>
        </li>
        <li>
          <a :class="{selected:type ==='completed'}"  @click.prevent="changeType('completed')" href="#/completed">已完成</a>
        </li>
      </ul>
      <button class="clear-completed" @click="clearList">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'MyFooter',
  props: {
    list: {
      type: Array,
      default: () => []
    },
    type: String
  },
  components: {},
  data () {
    return {}
  },
  methods: {
    clearList () {
      this.$emit('clearList')
    },
    changeType (type) {
      this.$emit('changeType', type)
    }
  },

  computed: {
    last () {
      return this.list.filter(item => item.edit === false).length
    }
  }
}
</script>

<style scoped lang="less"></style>
